package script.node;

import cn.hutool.core.util.HexUtil;
import com.gee.spring.cloud.aerospace.simulate.core.domain.TelemetryNodeDto;
import com.gee.spring.cloud.aerospace.simulate.core.satellite.telemetry.TmFrameGenerator;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author gepengjun
 * @since 2024/7/4 14:01
 */
public class DefaultValue {


    static byte[] eval(TmFrameGenerator tmFrameGenerator, TelemetryNodeDto currentNode,
                       List<TelemetryNodeDto> frameNodeList, Map<String, String> scriptParamMap){
        String defaultValue = scriptParamMap.get("defaultValue");
        int valueRadix = Integer.parseInt(scriptParamMap.get("valueRadix"));
        if (valueRadix == 16){
            return HexUtil.decodeHex(defaultValue);
        }
        long value = Long.parseLong(defaultValue, valueRadix);
        return HexUtil.decodeHex(HexUtil.toHex(value));
    }


    public static void main(String[] args) {
        Map<String, String> scriptParamMap = new HashMap<>();
        scriptParamMap.put("defaultValue", "352EF853");
        scriptParamMap.put("valueRadix", "16");

        byte[] eval = eval(null,  null, null, scriptParamMap);
        System.out.println(Arrays.toString(eval));
    }
}
